﻿using System;
using System.Windows.Forms;

namespace SingbonDES
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
      string original = inputStr.Text;
      outputStr.Text = Md5Des.DecryptDes(original, encryptStr.Text);
      //Singbon.Key.Md5Des.EncryptDES
    }

    private void button2_Click(object sender, EventArgs e)
    {
      string original = inputStr.Text;
      outputStr.Text = Md5Des.EncryptDes(original, encryptStr.Text);
    }

    /**
     * 库加密
     */
    private void button1_Click_1(object sender, EventArgs e)
    {
      string inputTxt = inputStr.Text;
      Md5Des.Md5Encrypt(inputTxt, out string str);
      outputStr.Text = str;
    }

    private void Form1_Load(object sender, EventArgs e)
    {
      inputStr.Focus();
    }

    /**
     * 库解密
     */
    private void btnDePwd_Click(object sender, EventArgs e)
    {
      string inputTxt = inputStr.Text;
      string decryptDesPwd = Md5Des.DecryptDes(inputTxt, "singbone");
      Console.WriteLine(decryptDesPwd);
      string decryptDesPwd2 = Md5Des2.DecryptDes(inputTxt, "singbone");
      Console.WriteLine(decryptDesPwd2);
      outputStr.Text = decryptDesPwd;
    }
  }
}